package com.farsight.leo.fssmartlock.db;

import java.util.List;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

/**
 * Author: Administrator
 * Date: 2019/9/17
 * Project: SmartLockApp
 * Description:
 */
@Dao
public interface DeviceDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    Long insertDevice(DeviceEntity entity);

    @Delete()
    void removeDevice(DeviceEntity entry);

    @Update(onConflict = OnConflictStrategy.REPLACE)
    void updateDevice(DeviceEntity entry);

    @Query("SELECT * FROM tbl_devices WHERE user_id=:user_id LIMIT 1")
    DeviceEntity query(int user_id);

    @Query("SELECT * FROM tbl_devices WHERE user_id=:user_id")
    List<DeviceEntity> queryAll(int user_id);
}
